import requests
from config import url, headers_web,headers_wechat

class CollegesGet:
    def __int__(self):
        self.url = url
        self.headers = headers_web
        self.headers2 = headers_wechat
    @classmethod
    def colleges_list(cls,url: str,headers= headers_web, params= None):
        '''
        @Summary:根据学院ids获取学院信息列表
        @Description:1、云课堂管理端督导听课使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/colleges"
        r = requests.get(url= url, params=params,headers=headers)
        return r

    @classmethod
    def college_info(cls,url: str, params= None,headers= headers_wechat):
        '''
        @Summary:获取开课学院信息
        @Description:小程序获取开课学院信息
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/college"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def college_list_info(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:学院列表信息
        @Description:
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/collegeResources"
        r = requests.get(url=url, params=params, headers=headers)
        return r

    @classmethod
    def college_all(cls, url: str, params=None,headers=headers_web):
        '''
        @Summary:获取所有学院
        @Description:数据对接使用
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/colleges/all"
        r = requests.get(url=url, params=params, headers=headers)
        return r

class CollegesPost:
    def __int__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def college_courseid(self,url:str,params=None,json=None,headers= headers_web):
        '''
        @Summary:根据课程ID获取学院信息
        @Description:1.teachingApi题库统计接口使用
        :param url:
        :param params:
        :param json:
        :return:
        '''
        url = url + "/courseApi/v1/college/courseid"
        r = requests.post(url=url, params=params, headers=headers,json=json)
        return r

    @classmethod
    def college_save(self,url:str,params=None,json=None,headers= headers_web):
        '''
        @Summary:保存学院
        @Description:数据对接使用
        :param url:
        :param params:
        :param json:
        :return:
        '''
        url = url + "/courseApi/v1/colleges"
        r = requests.post(url=url, params=params, headers=headers,json=json)
        return r

    @classmethod
    def college_singleSave(self, url: str, params=None, json=None,headers= headers_web):
        '''
        @Summary:保存单个学院
        @Description:数据对接使用
        :param url:
        :param params:
        :param json:
        :return:
        '''
        url = url + "/courseApi/v1/datadock/college"
        r = requests.post(url=url, params=params, headers=headers, json=json)
        return r

if __name__ == '__main__':
    from common.hashlib_utils import hash_md5

    valid_code = hash_md5("&signKey=123123")
    resp = CollegesPost.college_courseid(url,params={"validCode": valid_code},json=["2072605"])
    print(resp.url, "\n", resp, resp.content)
    print(resp.request.headers, "\n", resp.request.method)